package org.jeecg.modules.zcgl.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.modules.zcgl.service.IAssetFixedLogService;
import org.jeecg.modules.zcgl.service.IAssetFixedMaintenanceService;
import org.jeecg.modules.zcgl.vo.AssetLedgerVo;
import org.jeecg.modules.zcgl.vo.statistical.AssetBorrowVo;
import org.jeecg.modules.zcgl.vo.statistical.AssetMaintenanceVo;
import org.jeecg.modules.zcgl.vo.statistical.AssetReturnVo;
import org.jeecg.modules.zcgl.vo.statistical.AssetScrapVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 尹涛 * @version V1.0.0
 * @projectName bingjiang-parent
 * @title AssetFixedStatisticalController
 * @package org.jeecg.modules.zcgl.controller
 * @description
 * @date 2021/7/6
 */
@Api(tags = "固定资产统计报表")
@RestController
@RequestMapping("/zcgl/assetFixedStatistical")
@Slf4j
public class AssetFixedStatisticalController {

    @Autowired
    private IAssetFixedLogService assetFixedLogService;
    @Autowired
    private IAssetFixedMaintenanceService assetFixedMaintenanceService;
    /**
     * 固定资产借用统计
     *
     * @param vo
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "固定资产借用统计-分页列表查询")
    @ApiOperation(value = "固定资产借用统计-分页列表查询", notes = "固定资产借用统计-分页列表查询")
    @GetMapping(value = "/assetBorrow")
    public Result<IPage<AssetBorrowVo>> queryAssetFixedBorrowPageList(AssetBorrowVo vo,
                                                                      @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                      @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                      HttpServletRequest req) {
        vo.setSelections(null);
        QueryWrapper<AssetBorrowVo> queryWrapper = new QueryWrapper<>(vo);
        Page<AssetBorrowVo> page = new Page<>(pageNo, pageSize);
        IPage<AssetBorrowVo> pageList = assetFixedLogService.queryAssetFixedBorrowPageList(page, queryWrapper);
        return Result.ok(pageList);
    }

    /**
     * 固定资产归还统计
     *
     * @param vo
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "固定资产归还统计-分页列表查询")
    @ApiOperation(value = "固定资产归还统计-分页列表查询", notes = "固定资产归还统计-分页列表查询")
    @GetMapping(value = "/assetReturn")
    public Result<IPage<AssetReturnVo>> queryAssetFixedReturnPageList(AssetReturnVo vo,
                                                                      @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                      @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                      HttpServletRequest req) {
        vo.setSelections(null);
        QueryWrapper<AssetReturnVo> queryWrapper = new QueryWrapper<>(vo);
        Page<AssetReturnVo> page = new Page<>(pageNo, pageSize);
        IPage<AssetReturnVo> pageList = assetFixedLogService.queryAssetFixedReturnPageList(page, queryWrapper);
        return Result.ok(pageList);
    }


    /**
     * 固定资产维修统计
     *
     * @param vo
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "固定资产维修统计-分页列表查询")
    @ApiOperation(value = "固定资产维修统计-分页列表查询", notes = "固定资产维修统计-分页列表查询")
    @GetMapping(value = "/assetMaintenance")
    public Result<IPage<AssetMaintenanceVo>> queryAssetFixedMaintenancePageList(AssetMaintenanceVo vo,
                                                                      @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                      @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                      HttpServletRequest req) {
        vo.setSelections(null);
        QueryWrapper<AssetMaintenanceVo> queryWrapper = new QueryWrapper<>(vo);
        Page<AssetMaintenanceVo> page = new Page<>(pageNo, pageSize);
        IPage<AssetMaintenanceVo> pageList = assetFixedMaintenanceService.queryAssetFixedMaintenancePageList(page, queryWrapper);
        return Result.ok(pageList);
    }


    /**
     * 固定资产报废统计
     *
     * @param vo
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "固定资产报废统计-分页列表查询")
    @ApiOperation(value = "固定资产报废统计-分页列表查询", notes = "固定资产报废统计-分页列表查询")
    @GetMapping(value = "/assetScrap")
    public Result<IPage<AssetScrapVo>> queryAssetFixedScrapPageList(AssetScrapVo vo,
                                                                     @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                     @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                     HttpServletRequest req) {
        vo.setSelections(null);
        QueryWrapper<AssetScrapVo> queryWrapper = new QueryWrapper<>(vo);
        Page<AssetScrapVo> page = new Page<>(pageNo, pageSize);
        IPage<AssetScrapVo> pageList = assetFixedMaintenanceService.queryAssetFixedScrapPageList(page, queryWrapper);
        return Result.ok(pageList);
    }


}
